home *** CD-ROM | disk | FTP | other *** search
/ STraTOS 1997 April & May / STraTOS 1 - 1997 April & May.iso / CD01 / PRGMANIA / @FALCON / VISUAL41 / SOURCE40 / LOOK / LOOK.S < prev    next >
Encoding:
Text File  |  1996-10-12  |  37.5 KB  |  1,755 lines

  1.     output d:\assemble\sources.v40\look\look.acx
  2.  
  3. OPT_FULL_PATHNAMES
  4.     lea objet_application,a1
  5.  
  6.     include look.def
  7.     include visual40.s
  8.     include look.hs
  9.     include look.obj
  10.  
  11.     comment HEAD=7
  12.     section TEXT
  13.  
  14. *--------------------------------------------------------------------------*
  15. initialisation_app:
  16.     clr.l add_structure_wind_look    ; il faut effacer les bss non initialisés ...
  17.  
  18.     save.l d0/a0
  19.  
  20.     move.w #FORM_SEARCH,d0
  21.     move.w #FSCH_TXT_ITEM,d1
  22.     bsr RETURN_TEXT_OBJ_IN_FORM_OBJ_PTR
  23.     clr.b (a1)            ; Par défaut pas de chaine de caractère de recherche
  24.  
  25.     move #FORMULAIRE_S,d0
  26.     move spec_fenetre_generale_s+GWVA_WFORM_OBJ_IS_CLONE_FORM,d1
  27.     move.l #0,a0
  28.     lea spec_fenetre_generale_s,a1
  29.     bsr GWVA_WFORM_OBJ_PRG_SAVE_FORM
  30.     tst d7
  31.     bmi .erreur1    ; annule l'ouverture si pas pu sauver
  32.     move.l a0,sauve_etat_formulaire_s
  33.  
  34.     move #FORMULAIRE_B,d0
  35.     move spec_fenetre_generale_b+GWVA_WFORM_OBJ_IS_CLONE_FORM,d1
  36.     move.l #0,a0
  37.     lea spec_fenetre_generale_b,a1
  38.     bsr GWVA_WFORM_OBJ_PRG_SAVE_FORM
  39.     tst d7
  40.     bmi .erreur2    ; annule l'ouverture si pas pu sauver
  41.     move.l a0,sauve_etat_formulaire_b
  42.  
  43.     move #FORM_ASK_OFFSET,d0
  44.     move spec_fenetre_offset+GWVA_WFORM_OBJ_IS_CLONE_FORM,d1
  45.     move.l #0,a0
  46.     lea spec_fenetre_offset,a1
  47.     bsr GWVA_WFORM_OBJ_PRG_SAVE_FORM
  48.     tst d7
  49.     bmi.s .erreur3    ; annule l'ouverture si pas pu sauver
  50.     move.l a0,sauve_etat_formulaire_offset
  51.  
  52.     move #FORM_SEARCH,d0
  53.     move spec_fenetre_search+GWVA_WFORM_OBJ_IS_CLONE_FORM,d1
  54.     move.l #0,a0
  55.     lea spec_fenetre_search,a1
  56.     bsr GWVA_WFORM_OBJ_PRG_SAVE_FORM
  57.     tst d7
  58.     bmi.s .erreur4    ; annule l'ouverture si pas pu sauver
  59.     move.l a0,sauve_etat_formulaire_search
  60.  
  61.     clr.l pointeur_principal_clone_window_general_s
  62.     clr.l pointeur_principal_clone_window_general_b
  63.     clr.l pointeur_principal_clone_window_offset
  64.     clr.l pointeur_principal_clone_window_search
  65.  
  66.     load.l d0/a0
  67.  
  68.     tst GWVA_APP_OBJ_IS_ACC_PRG
  69.     beq.s .pas_de_demarage_si_acc
  70.  
  71.     lea liste_obj_form_b,a2        ; par défaut l'ouverture se fait sur le grand formulaire
  72.  
  73.     tst d0            ; ligne de commande présente = a0.l : ptr sur le nom du fichier
  74.     bne create_open_a_look_window
  75.  
  76.     bra menu_open_look
  77.  
  78. .pas_de_demarage_si_acc:
  79.     rts
  80.  
  81. .erreur4:    MFREE sauve_etat_formulaire_offset
  82.     clr.l sauve_etat_formulaire_offset
  83. .erreur3:    MFREE sauve_etat_formulaire_b
  84.     clr.l sauve_etat_formulaire_b
  85. .erreur2:    MFREE sauve_etat_formulaire_s
  86.     clr.l sauve_etat_formulaire_s
  87. .erreur1:    load.l d0/a0
  88.     bra.s menu_quit
  89.  
  90.  BSS
  91. sauve_etat_formulaire_search:        ds.l 1
  92. sauve_etat_formulaire_offset:        ds.l 1
  93. sauve_etat_formulaire_b:        ds.l 1
  94. sauve_etat_formulaire_s:        ds.l 1
  95.  
  96. pointeur_principal_clone_window_general_s:    ds.l 1
  97. pointeur_principal_clone_window_general_b:    ds.l 1
  98. pointeur_principal_clone_window_offset:    ds.l 1
  99. pointeur_principal_clone_window_search:    ds.l 1
  100.  TEXT
  101. *--------------------------------------------------------------------------*
  102.  
  103. acc_open:    
  104. menu_open_look:
  105.     lea texte_selecteur_l,a0    ; 35 chars max.
  106.     lea mask_selecteur_l,a1        ; 18 caracteres max
  107.     lea 0,a2            ; ancien pathname
  108.     bsr FILE_SELECTOR
  109.     tst d0
  110.     beq.s .annule
  111.     bmi.s .erreur_gemdos
  112. ;     -> a0 : nom du fichier
  113. ;    -> a1 : drive:path\ du fichier
  114. ;    -> a2 : drive:path\filename.ext
  115.  
  116.     move.l a2,a0        ; nom fichier
  117.     lea liste_obj_form_b,a2        ; par défaut l'ouverture se fait sur le grand formulaire
  118.     bra create_open_a_look_window
  119.  
  120. .erreur_gemdos:
  121. .annule:
  122.     rts
  123.  
  124.     *-------------------------*
  125. acc_close:
  126. app_term:
  127. menu_quit:
  128.     bsr free_all_look_window
  129.  
  130.     bsr GWVA_WIND_OBJ_PRG_DELETE_ALL_WIND
  131.  
  132.     MFREE sauve_etat_formulaire_search
  133.     clr.l sauve_etat_formulaire_search
  134.     MFREE sauve_etat_formulaire_offset
  135.     clr.l sauve_etat_formulaire_offset
  136.     MFREE sauve_etat_formulaire_b
  137.     clr.l sauve_etat_formulaire_b
  138.     MFREE sauve_etat_formulaire_s
  139.     clr.l sauve_etat_formulaire_s
  140.  
  141.     tst GWVA_APP_OBJ_IS_ACC_PRG
  142.     bne VISUAL40_END
  143.  
  144. ; les accesoires ne sortent pas
  145.     rts
  146.  
  147.     *-------------------------*
  148.  
  149. menu_info:    lea fenetre_information,a0
  150.     bra GWVA_WIND_OBJ_PRG_CREATE_OPEN_ONE_WIND
  151.  
  152. *--------------------------------------------------------------------------*
  153.  
  154. other_message:
  155.     cmp.w #VA_START,d0
  156.     beq.s .va_start
  157.     rts
  158.  
  159. .va_start:    move.l 6(a0),a0    ; a0 pointe sur le nom du fichier
  160.  
  161.     save.l a0
  162.     bsr GWVA_APP_OBJ_PRG_ACC_OPEN_VSTATION    ; on doit ouvrir la station virtuelle
  163.     load.l a0
  164.  
  165.     lea liste_obj_form_b,a2        ; par défaut l'ouverture se fait sur le grand formulaire
  166.     tst d7
  167.     bpl create_open_a_look_window
  168.  
  169.     rts
  170.  
  171.     *-------------------------*
  172.  
  173. event_keyboard:
  174. ; Traitement des touches pour l'édition des fichiers
  175.  
  176.     cmp.l #0,a0        ; Est-ce une fenêtre Visual
  177.     beq .pas_de_fenetre
  178.  
  179.     move.l GWVA_WIND_OBJ_USER_PTR1(a0),a1
  180.     cmp.l #0,a1        ; Est-ce que l'on a un fichier dans cette fenêtre ?
  181.     beq .pas_fenetre_edition
  182.  
  183.     tst.l ad_buffer_source(a1)    ; ?PROT?
  184.     beq .pas_de_fichier
  185.  
  186. ; Je suis en edition dans le champs hexa ou ascii ?
  187.     btst #0,champ_edition+1(a1)
  188.     bne.s .edition_ascii
  189.  
  190. ; On test si la touche est un chiffre hexadécimal
  191.  
  192.     move d0,d1
  193.     cmp.b #'0',d0
  194.     blt .pas_affichable
  195.     cmp.b #'f',d0
  196.     bgt .pas_affichable
  197.  
  198.     cmp.b #'9',d0
  199.     ble.s .number
  200.  
  201.     or.b #$20,d0    ; on transforme la lettre en minuscule
  202.     cmp.b #'a',d0
  203.     blt .pas_affichable
  204.     cmp.b #'f',d0
  205.     bgt .pas_affichable
  206. .number:    ; le caractere est un digit hexadecimal valide
  207.  
  208.     ; d1 est un caractère valide pour l'hexa
  209.     move d1,d0
  210.     ext.w d0
  211.     sub.w #'0',d0
  212.     cmp.w #9,d0
  213.     ble.s .hexa_number
  214.     or.w #$20,d0
  215.     sub.w #('a'-'0')-$0a,d0
  216. .hexa_number:
  217. .edition_ascii:
  218.     bsr affiche_digit
  219. .pas_affichable
  220. .pas_de_fichier:
  221. .pas_fenetre_edition:
  222. .pas_de_fenetre:
  223.     rts
  224.  
  225.  
  226. *--------------------------------------------------------------------------*
  227. ; Fenêtre Générale
  228.  
  229. curseur_droite:
  230.     bsr deplacement_curseur
  231.     move.l d3,d0
  232.     move.w #0,d1
  233.     bsr update_position_curs
  234.     rts
  235. curseur_gauche:
  236.     bsr deplacement_curseur
  237.     move.l d3,d0
  238.     neg.l d0
  239.     move.w #0,d1
  240.     bsr update_position_curs
  241.     rts
  242. curseur_bas:
  243.     bsr deplacement_curseur
  244.     move.l d2,d0
  245.     move.w #0,d1
  246.     bsr update_position_curs
  247.     rts
  248. curseur_haut:
  249.     bsr deplacement_curseur
  250.     move.l d2,d0
  251.     neg.l d0
  252.     move.w #0,d1
  253.     bsr update_position_curs
  254.     rts
  255.  
  256.     *-------------------------*
  257. top_fenetre_generale:
  258.     tst GWVA_WIND_OBJ_TOPABLE_STATE(a0)
  259.     bgt.s .pas_toppable
  260.     clr.w d7
  261.     rts
  262. .pas_toppable:
  263. ; Si je suis pas topable, c'est une fenetre GO_OFFSET ou SEARCH existe
  264. ; Le but du jeux va etre de faire apparaitre en premier plan la fenetre look,
  265. ; puis la fentre offset (si elle existe) puis la fenetre search (si elle exite)
  266.  
  267.     save.l a0
  268.     wind_set GWVA_WIND_OBJ_GEM_HANDLE(a0),#WF_TOP
  269.     load.l a0
  270.  
  271.     save.l a0
  272.     move.l GWVA_WIND_OBJ_USER_PTR1(a0),a1
  273.     move.l ad_fenetre_go_offset(a1),a0
  274.     cmp.l #0,a0
  275.     beq.s .pas_de_fenetre_offset
  276.     wind_set GWVA_WIND_OBJ_GEM_HANDLE(a0),#WF_TOP
  277. .pas_de_fenetre_offset:
  278.     load.l a0
  279.  
  280.     save.l a0
  281.     move.l GWVA_WIND_OBJ_USER_PTR1(a0),a1
  282.     move.l ad_fenetre_search(a1),a0
  283.     cmp.l #0,a0
  284.     beq.s .pas_de_fenetre_search
  285.     wind_set GWVA_WIND_OBJ_GEM_HANDLE(a0),#WF_TOP
  286. .pas_de_fenetre_search:
  287.     load.l a0
  288.  
  289.     move.w #-1,d7
  290.     rts
  291.     *-------------------------*
  292.  
  293. close_fenetre_generale:
  294.     move.l GWVA_WIND_OBJ_USER_PTR1(a0),a1    ; pointeur structure look
  295.  
  296.     bsr close_a_look_window
  297.  
  298.     tst.l add_structure_wind_look
  299.     beq menu_quit    ; plus de fenetre -> on quitte
  300.     rts
  301.  
  302.     *-------------------------*
  303.  
  304. affichage_curseur:
  305.     move.l GWVA_WIND_OBJ_USER_PTR1(a0),a2    ; pointe la structure look
  306.     cmp.l #0,a2        ; ?PROT?
  307.     beq .pas_redraw
  308.  
  309.     tst.l ad_buffer_source(a2)    ; ?PROT?
  310.     beq .pas_redraw
  311.  
  312.     move.l pos_curseur(a2),d1    ; position curseur / debut fichier en quartet
  313.     lsr.l #1,d1            ; en octet
  314.     sub.l offset_fichier(a2),d1    ; pos. / debut buffer
  315.     divu #8+8,d1        ; n. de la ligne
  316.     move.l table_obj(a2),a3
  317.     add.w f_donnees_byte(a3),d1    ; + n. premiere ligne
  318.  
  319.     save.l d1/a0-a2
  320.     objc_offset GWVA_WFORM_OBJ_FORM_PTR(a1),d1
  321.     load.l d1/a0-a2
  322.     movem.w int_out+1*2,d4/d5    ; position x,y de l'objet
  323.  
  324.     swap d1
  325.     ext.l d1
  326.     divu #8,d1        ; -> 1ere ou 2eme partie de la ligne
  327.  
  328.     clr.w d3
  329.  
  330.     tst.w d1
  331.     beq.s .premier_8
  332.  
  333.     move.w GWVA_APP_OBJ_CELL_WIDTH,d2
  334.     move.w d2,d3
  335.     mulu #8*3,d3    ; 3 ascii pour un caractere : 00[ ]
  336.     ext.l d2
  337.     add.l d2,d3        ; caracteres de passage entre 2 champs
  338.     add.l d2,d3
  339.  
  340. .premier_8:    swap d1
  341.     mulu #3,d1        ; 3 ascii par octet
  342.     move.l pos_curseur(a2),d0
  343.     sub.l offset_fichier(a2),d0
  344.     sub.l offset_fichier(a2),d0    ; octet -> quartet
  345.     divu #2,d0        ; on passe la position octet
  346.     swap d0
  347.     add.w d0,d1
  348.     mulu GWVA_APP_OBJ_CELL_WIDTH,d1
  349.     add.w d1,d3        ; position x/objet
  350.     add.w d4,d3        ; position x absolue
  351.  
  352.     move d5,d7
  353.     move d3,d4
  354.     move d3,d6
  355.     add GWVA_APP_OBJ_CELL_WIDTH,d6
  356.     add GWVA_APP_OBJ_CELL_HEIGHT,d7    ; coin droit bas
  357.     sub.w #1,d6
  358.     sub.w #1,d7
  359.  
  360.     save.l a0-a2
  361.  
  362.     save.l a2
  363.     save.w d4-d7
  364.     vswr_mode #3    ; mode XOR
  365.     load.w d4-d7
  366.     load.l a2
  367.  
  368.     btst #0,champ_edition+1(a2)
  369.     bne.s .pas_edition_champ_hexa
  370.  
  371.     vr_recfl d4,d5,d6,d7    ; rectangle plein
  372.     bra.s .comm1
  373.  
  374. .pas_edition_champ_hexa:
  375.     save.w d4-d7
  376.     vsf_interior #0    ; pas de remplissage
  377.     load.w d4-d7
  378.     v_bar d4,d5,d6,d7    ; rectangle avec bord
  379.     vsf_interior #1    ; remet le remplissage
  380. .comm1:
  381.     vswr_mode #1    ; mode de remplacement
  382.  
  383.     load.l a0-a2
  384.  
  385.     move.l pos_curseur(a2),d1
  386.     lsr.l #1,d1
  387.     sub.l offset_fichier(a2),d1    ; pos. / debut buffer
  388.     divu #8+8,d1
  389.     move.l table_obj(a2),a3
  390.     add.w f_ascii_byte(a3),d1
  391.  
  392.     save.l d1/a0-a2
  393.     objc_offset GWVA_WFORM_OBJ_FORM_PTR(a1),d1
  394.     load.l d1/a0-a2
  395.     movem.w int_out+1*2,d4/d5
  396.  
  397.     swap d1
  398.     mulu GWVA_APP_OBJ_CELL_WIDTH,d1    ; position x/objet
  399.     add.w d4,d1            ; position x absolue
  400.  
  401.     move.w d5,d7
  402.     move.w d1,d4
  403.     move.w d1,d6
  404.     add GWVA_APP_OBJ_CELL_WIDTH,d6
  405.     add GWVA_APP_OBJ_CELL_HEIGHT,d7    ; coin droit bas
  406.     sub.w #1,d6
  407.     sub.w #1,d7
  408.  
  409.     save.l a0-a2
  410.  
  411.     save.l a2
  412.     save.w d4-d7
  413.     vswr_mode #3    ; mode XOR
  414.     load.w d4-d7
  415.     load.l a2
  416.  
  417.     btst #0,champ_edition+1(a2)
  418.     beq.s .pas_edition_champ_ascii
  419.  
  420.     vr_recfl d4,d5,d6,d7
  421.     bra.s .comm2
  422. .pas_edition_champ_ascii:
  423.     save.w d4-d7
  424.     vsf_interior #0
  425.     load.w d4-d7
  426.     v_bar d4,d5,d6,d7
  427.     vsf_interior #1
  428. .comm2:
  429.     vswr_mode #1
  430.  
  431.     load.l a0-a2
  432.  
  433. .pas_redraw:
  434.     clr.w d7
  435.     rts
  436.  
  437.     *-------------------------*
  438.  
  439. ; Initialisation_fenetre : Initialise le contenu des champs graphiques de la fenêtre look
  440. initialisation_fenetre:
  441.     move.l GWVA_WIND_OBJ_USER_PTR1(a0),a1    ; structure look
  442.     move.l table_obj(a1),a2
  443.  
  444.     move.l GWVA_WIND_OBJ_SPEC_PTR(a0),a3
  445.  
  446. ; On recopie le nom dans les deux formulaires
  447.  
  448.     move.w GWVA_WFORM_OBJ_FORM_IDX(a3),d0
  449.     move.w f_txt_name(a2),d1
  450.     save.l a0-a3
  451.     bsr RETURN_TEXT_OBJ_IN_FORM_OBJ_PTR
  452.     move.l a1,a4
  453.     load.l a0-a3
  454.     lea source_pathname(a1),a5
  455. .rec:    tst.b (a5)+
  456.     bne.s .rec
  457. .rec2:    cmp.b #'\',-(a5)
  458.     bne.s .rec2
  459.     lea 1(a5),a5
  460.     COPY_STRING_0 a5,a4
  461.  
  462. ; Ainsi que la taille
  463.  
  464.     move.w GWVA_WFORM_OBJ_FORM_IDX(a3),d0
  465.     move.w f_txt_lgth_hex(a2),d1
  466.     save.l a0-a3
  467.     save.l a1
  468.     bsr RETURN_TEXT_OBJ_IN_FORM_OBJ_PTR
  469.     load.l a0
  470.     move.b #'$',(a1)+
  471.     move.l source_length(a0),d0
  472.     move.l #32,d1
  473.     bsr STOCK_HEXA
  474.     load.l a0-a3
  475.  
  476.     move.w GWVA_WFORM_OBJ_FORM_IDX(a3),d0
  477.     move.w f_txt_lgth_dec(a2),d1
  478.     save.l a0-a3
  479.     save.l a1
  480.     bsr RETURN_TEXT_OBJ_IN_FORM_OBJ_PTR
  481.     load.l a0
  482.     move.b #'#',(a1)+
  483.     move.l source_length(a0),d0
  484.     bsr STOCK_DECI
  485.     load.l a0-a3
  486.  
  487.     save.l a0-a2
  488.     lea source_pathname(a1),a2
  489.     move.l a2,GWVA_WIND_OBJ_NAME(a0)
  490.     bsr GWVA_WIND_OBJ_PRG_UPDATE_WIND_TITLE
  491.     load.l a0-a2
  492.  
  493.     move.l add_struct_slide(a2),a3
  494.     add.l a0,a3
  495.     move.l source_length(a1),d0
  496.     add.l #8+8-1,d0
  497.     divu.l #8+8,d0
  498.     cmp.l GWVA_FORM_SLIDER_OBJ_SIZE(a3),d0
  499.     bge.s .pere_plus_grand_que_fils
  500.     move.l GWVA_FORM_SLIDER_OBJ_SIZE(a3),d0
  501. .pere_plus_grand_que_fils:
  502.     move.l d0,GWVA_FORM_SLIDER_OBJ_LENGTH(a3)
  503.     move.l offset_fichier(a1),d0
  504.     divu.l #8+8,d0
  505.     move.l d0,GWVA_FORM_SLIDER_OBJ_POS(a3)
  506.  
  507.     save.l a0-a2
  508.     move.l GWVA_WIND_OBJ_SPEC_PTR(a0),a1
  509.  
  510.     move.l add_struct_slide(a2),a2
  511.     add.l a0,a2
  512.     bsr GWVA_SLIDER_OBJ_PRG_SET_SLIDER
  513.     load.l a0-a2
  514.  
  515.     clr.w longueur_chaine_search(a1)
  516.     clr.b chaine_search(a1)
  517.     clr.l ad_buffer_search(a1)
  518.  
  519.     clr.l ad_fenetre_go_offset(a1)
  520.     clr.l ad_fenetre_search(a1)
  521.  
  522.     clr.w d7
  523.     rts
  524.  
  525.     *-------------------------*
  526.  
  527. click_in_window:
  528.     move.l GWVA_WIND_OBJ_USER_PTR1(a0),a1
  529.  
  530.     move.l table_obj(a1),a2
  531.     
  532.     move f_donnees_byte(a2),d1
  533.     cmp.w d1,d0
  534.     blt .pas_click_champ_curseur
  535.     add.w f_num_line(a2),d1
  536.     cmp.w d1,d0
  537.     bge .pas_click_dans_donnees
  538. ; Click dans un champ donnée
  539.  
  540.     lsl.w champ_edition(a1)
  541.     bclr #0,champ_edition+1(a1)
  542.  
  543.     move.l GWVA_WIND_OBJ_SPEC_PTR(a0),a3
  544.  
  545.     save.l d0/a0-a3
  546.     objc_offset GWVA_WFORM_OBJ_FORM_PTR(a3),d0
  547.     load.l d0/a0-a3
  548.  
  549.     move.w int_out+1*2,d3
  550.     sub.w GWVA_APP_OBJ_EVNT_MULTI_MX,d3
  551.     neg.w d3            ; position relative souris / objet
  552.  
  553.     clr d4
  554.     move.w GWVA_APP_OBJ_CELL_WIDTH,d1
  555.     mulu #8*3,d1
  556.  
  557.     cmp.w d1,d3
  558.     blt.s .partie_gauche_donnees
  559.  
  560.     add.w GWVA_APP_OBJ_CELL_WIDTH,d1
  561.     add.w GWVA_APP_OBJ_CELL_WIDTH,d1
  562.  
  563.     cmp.w d1,d3
  564.     blt .au_milieu    ; on est au milieu des deux champs de donnees
  565.  
  566.     move.w #8*2,d4    ; décalage en quartet
  567.     sub.w d1,d3
  568.  
  569. .partie_gauche_donnees:
  570.     move.w GWVA_APP_OBJ_CELL_WIDTH,d1
  571.     mulu #3,d1
  572.     ext.l d3
  573.     divu d1,d3
  574.     move d3,d5
  575.     add.w d5,d5            ; numero quartet
  576.     swap d3
  577.     ext.l d3
  578.     divu GWVA_APP_OBJ_CELL_WIDTH,d3
  579.     cmp.w #2,d3
  580.     blt.s .ok
  581.     move.w #1,d3
  582. .ok:    add.w d3,d5
  583.     add.w d5,d4
  584.  
  585.     sub.w f_donnees_byte(a2),d0    ; la ligne
  586.     mulu #(8+8)*2,d0
  587.     add.w d4,d0
  588.     ext.l d0
  589.     add.l offset_fichier(a1),d0
  590.     add.l offset_fichier(a1),d0    ; position en quartet
  591.     sub.l pos_curseur(a1),d0
  592.     moveq #0,d1
  593.     bsr update_position_curs
  594.  
  595. .au_milieu:
  596.     rts
  597.  
  598. .pas_click_dans_donnees:
  599.     move f_ascii_byte(a2),d1
  600.     cmp.w d1,d0
  601.     blt .pas_click_champ_curseur
  602.     add.w f_num_line(a2),d1
  603.     cmp.w d1,d0
  604.     bge .pas_click_dans_ascii
  605.  
  606.     lsl.w champ_edition(a1)
  607.     bset #0,champ_edition+1(a1)
  608.  
  609.     move.l GWVA_WIND_OBJ_SPEC_PTR(a0),a3
  610.  
  611.     save.l d0/a0-a3
  612.     objc_offset GWVA_WFORM_OBJ_FORM_PTR(a3),d0
  613.     load.l d0/a0-a3
  614.  
  615.     move.w int_out+1*2,d3
  616.     sub.w GWVA_APP_OBJ_EVNT_MULTI_MX,d3
  617.     neg.w d3            ; position relative souris / objet
  618.  
  619.     ext.l d3
  620.     divu GWVA_APP_OBJ_CELL_WIDTH,d3
  621.     move d3,d5
  622.     add.w d5,d5            ; numero quartet
  623.  
  624.     sub.w f_ascii_byte(a2),d0    ; la ligne
  625.     mulu #(8+8)*2,d0
  626.     add.w d5,d0
  627.     ext.l d0
  628.     add.l offset_fichier(a1),d0
  629.     add.l offset_fichier(a1),d0
  630.     sub.l pos_curseur(a1),d0
  631.     moveq #0,d1
  632.     bsr update_position_curs
  633.     rts
  634. .pas_click_dans_ascii:
  635. .pas_click_champ_curseur:
  636.     rts
  637.  
  638.     *-------------------------*
  639.  
  640. size_changed:
  641.     lea liste_obj_form_b,a2
  642.     cmp.w #FS_BTON_BIG,d0
  643.     beq.s .big
  644.     lea liste_obj_form_s,a2
  645. .big:
  646.     move.l GWVA_WIND_OBJ_USER_PTR1(a0),a1
  647.     move.l f_buffer_length(a2),d0
  648.  
  649.     save.l a0-a2
  650.     bsr reserve_buffer    ; -> d0.l
  651.     load.l a0-a2
  652.     tst d7
  653.     beq .ok_memoire
  654.  
  655.     rts
  656.  
  657. .ok_memoire:
  658.     save.l a0-a2
  659.     MFREE d0
  660.     movem.l (sp),a0-a2
  661.     bsr GWVA_WIND_OBJ_PRG_DELETE_ONE_WIND
  662.     load.l a0-a2
  663.  
  664.     tst.l ad_buffer_source(a1)
  665.     beq .buffer_vide
  666.  
  667.     save.l a0-a2
  668.     move.w #2,d0        ; par défaut No
  669.     bsr save_buffer_if_changed
  670.     movem.l (sp),a0-a2
  671.     MFREE ad_buffer_source(a1)
  672.     load.l a0-a2
  673.     clr.l ad_buffer_source(a1)
  674.  
  675. .buffer_vide:
  676.     move.l f_buffer_length(a2),d0
  677.     save.l a0-a2
  678.     bsr reserve_buffer    ; -> d0.l
  679.     load.l a0-a2
  680.     tst d7
  681.     bmi .erreur_memoire
  682.     move.l d0,ad_buffer_source(a1)
  683.  
  684.     move.l f_buffer_length(a2),buffer_length(a1)
  685.     move.w f_num_line(a2),buffer_num_line(a1)
  686.     move.w f_size(a2),size_look(a1)
  687.     move.l a2,table_obj(a1)
  688.  
  689.     save.l a0-a2
  690.     bsr load_a_buffer
  691.     load.l a0-a2
  692.     tst d7
  693.     bne .erreur_load
  694.  
  695.     save.l a0-a2        ; on doit créer une copie du nouveau formulaire
  696.     move.l add_ptr_copy_form(a2),a0
  697.     move.l (a0),a0
  698.     move.l #0,a1
  699.     bsr GWVA_WFORM_OBJ_PRG_COPY_SAVED_FORM
  700.     move.l a0,a3
  701.     load.l a0-a2
  702.     tst d7
  703.     bmi .erreur_copy
  704.  
  705.     move.l #-1,GWVA_WIND_OBJ_FIRST_X(a0)    ; centre
  706.     move.l add_struct_form(a2),d0
  707.     add.l a0,d0
  708.     move.l d0,GWVA_WIND_OBJ_SPEC_PTR(a0)
  709.  
  710.     move.l GWVA_WIND_OBJ_SPEC_PTR(a0),a4
  711.     move.l a3,GWVA_WFORM_OBJ_CLONE_FORM_SAVE(a4)
  712.  
  713.     move.l pos_curseur(a1),d0
  714.     move.l offset_fichier(a1),d1
  715.     add.l buffer_length(a1),d1
  716.     add.l d1,d1
  717.     cmp.l d0,d1
  718.     bgt.s .curseur_dans_champ
  719.     move.l d1,d0
  720.     sub.l #(8+8)*2,d0    ; position en dernière ligne
  721. .curseur_dans_champ:
  722.  
  723.     save.l d0/a1
  724.     bsr GWVA_WIND_OBJ_PRG_CREATE_OPEN_ONE_WIND
  725.     load.l d0/a1
  726.  
  727.     sub.l pos_curseur(a1),d0
  728.     move.w #0,d1
  729.     bsr update_position_curs
  730.     tst d7
  731.     bpl.s .ok_actualisation_text
  732.     bsr update_text_dans_formulaire
  733. .ok_actualisation_text:
  734.     rts
  735. .erreur_copy:
  736. .erreur_memoire:
  737. .erreur_load:
  738.     bsr free_a_look_window
  739.     rts
  740.  
  741.     *-------------------------*
  742.  
  743. ; Update_file : demande de sauvegarder le buffer actuel
  744. update_file:
  745.     move.l GWVA_WIND_OBJ_USER_PTR1(a0),a1
  746.  
  747.     tst.l ad_buffer_source(a1)
  748.     beq .buffer_vide
  749.  
  750.     move.w changement_valeur(a1),-(sp)
  751.     move.w #1,d0        ; par défaut yes
  752.     bsr save_buffer_if_changed
  753.     load.w d0
  754.     tst.w d7
  755.     beq.s .sauvegarde
  756.     move.w d0,changement_valeur(a1)    ; si pas updaté, on garde le chgt actif
  757. .sauvegarde:
  758. .buffer_vide:
  759.     rts
  760.  
  761.     *-------------------------*
  762.  
  763. ; Load_file  : charge un nouveau fichier dans la fenêtre look actuelle
  764. load_file:    save.l a0
  765.  
  766.     lea texte_selecteur_l,a0    ; 35 chars max.
  767.     lea mask_selecteur_l,a1        ; 18 caracteres max
  768.     lea 0,a2
  769.     bsr FILE_SELECTOR
  770.  
  771.     load.l a0
  772.  
  773.     tst d0
  774.     beq.s .annule
  775.     bmi.s .erreur_gemdos
  776. ;     -> a0 : nom du fichier
  777. ;    -> a1 : drive:path\ du fichier
  778. ;    -> a2 : drive:path\filename.ext
  779.  
  780.     save.l a2
  781.     move.l GWVA_WIND_OBJ_USER_PTR1(a0),a1
  782.     move.l table_obj(a1),-(sp)    ; on sauve le type de formulaire précédent
  783.     bsr close_a_look_window        ; on efface l'ancienne fenetre look
  784.     load.l a3
  785.     load.l a2
  786.     
  787.     move.l a2,a0        ; nom fichier
  788.     move.l a3,a2
  789.     bra create_open_a_look_window    ; on cree un nouvelle fenetre look
  790.  
  791. .erreur_gemdos:
  792. .annule:
  793.     rts
  794.  
  795.     *-------------------------*
  796.  
  797. move_slider:
  798.     move.l GWVA_WIND_OBJ_USER_PTR1(a0),a1
  799.     move.l d1,d0
  800.     muls.l #(8+8)*2,d0    ; taille d'un element = (8+8)*2 quartets
  801.     move.w #1,d1
  802.     bsr update_position_curs
  803.     rts
  804.  
  805. *--------------------------------------------------------------------------*
  806.  
  807. ; Sous Programme de la fenêtre Générale
  808.  
  809. deplacement_curseur:
  810.     move.l #(8+8)*2,d2    ; une ligne en quartet
  811.     moveq #1,d3
  812.     move.l GWVA_WIND_OBJ_USER_PTR1(a0),a1
  813.     btst #0,champ_edition(a1)
  814.     beq.s .edition_hexa
  815.     moveq #1*2,d3    ; 2 quartets par 2 quartets en ASCII
  816. .edition_hexa:
  817.     rts
  818.  
  819.     *-------------------------*
  820.  
  821. ; d0.l : déplacement signé du curseur en quartet
  822. ; d1.w : 0, déplacement, 1 pas deplacement curseur
  823. ; a0.l : ptr struct fenetre
  824. ; a1.l : ptr struct look
  825. update_position_curs:
  826.     move.l pos_curseur(a1),d2
  827.     add.l d0,d2
  828.     bpl.s .position_positive
  829. ;    sub.l d0,d2        ; quand on dépasse les limites du fichier, soit
  830.     moveq #0,d2        ; on ne bouge pas, soit on sature
  831. .position_positive:
  832.     move.l source_length(a1),d3    ; en octet
  833.     add.l d3,d3            ; en quartet
  834.     cmp.l d3,d2
  835.     blt.s .position_inf
  836. ;    sub.l d0,d2
  837.     move.l d3,d2
  838.     sub.l #1*2,d2
  839. .position_inf:
  840.  
  841.     move.w champ_edition(a1),d4    ; a-t-on changé d'édition
  842.     move.w d4,d5
  843.     and.w #%1,d4        ; edition actuelle (hexa, ascii)
  844.     and.w #%10,d5        ; edition précédente
  845.     lsr.w #1,d5
  846.     eor.w d4,d5            ; si on a changé d'édition, il faut comme même faire un affichage
  847.     bne.s .changement_edition    ; si on a pas bougé
  848.  
  849.     cmp.l pos_curseur(a1),d2
  850.     beq .pas_deplacement
  851.  
  852. .changement_edition:
  853.     move.l pos_curseur(a1),d3
  854.     move.l d2,pos_curseur(a1)
  855.  
  856.     tst.w d1
  857.     bne.s .curs_fixe
  858.  
  859.     moveq #0,d0        ; deplacement dans le fichier
  860.     move.l offset_fichier(a1),d4
  861.     add.l d4,d4
  862.     cmp.l d4,d2
  863.     bge.s .curs_sup_off
  864.  
  865.     move.l d4,d0    ; pour remonter en arrière dans le fichier
  866.     sub.l d2,d0
  867.     add.l #(8+8)*2-1,d0
  868.     and.l #-(8+8)*2,d0    ; on remonte d'une ligne complète dans le fichier
  869.     neg.l d0
  870. .curs_sup_off:
  871.     add.l buffer_length(a1),d4
  872.     add.l buffer_length(a1),d4
  873.     cmp.l d4,d2
  874.     blt.s .curs_dans_fenetre
  875.  
  876.     move.l d2,d0    ; pour descendre en avant dans le fichier
  877.     sub.l d4,d0
  878.     add.l #(8+8)*2,d0
  879.     and.l #-(8+8)*2,d0    ; on descend d'une ligne complète dans le fichier
  880.  
  881. .curs_dans_fenetre:
  882. .curs_fixe:
  883.     save.l a0-a1/d2/d3
  884.     bsr deplace_dans_fichier
  885.     load.l a0-a1/d2/d3
  886.     tst d7
  887.     beq.s .deja_un_affichage
  888.  
  889.     lsr.l #1,d2            ; nouvelle position curs. en octet
  890.     lsr.l #1,d3            ; ancienne position curs. en octet
  891.     and.l #-(8+8),d2
  892.     and.l #-(8+8),d3
  893.     sub.l offset_fichier(a1),d2
  894.     sub.l offset_fichier(a1),d3    ; pos. / debut buffer
  895.     divu #8+8,d2
  896.     divu #8+8,d3        ; n. de la ligne
  897.     move.w d2,d4
  898.     move.w d3,d5
  899.     move.l table_obj(a1),a2
  900.     add.w f_donnees_byte(a2),d2
  901.     add.w f_donnees_byte(a2),d3    ; + n. premiere ligne
  902.     add.w f_ascii_byte(a2),d4
  903.     add.w f_ascii_byte(a2),d5
  904.  
  905.     lea liste_obj_redraw,a3        ; liste d'objet pour le redraw_part
  906.     move.w d3,(a3)+
  907.     move.w #1,(a3)+
  908.     move.w d5,(a3)+
  909.     move.w #1,(a3)+
  910.     move.w d2,(a3)+
  911.     move.w #1,(a3)+
  912.     move.w d4,(a3)+
  913.     move.w #1,(a3)+
  914.     move.w #-1,(a3)+
  915.  
  916.     cmp.w d2,d3            ; si on est sur la même ligne, on a un seul objet
  917.     bne.s .lignes_differentes
  918.     move.w #-1,liste_obj_redraw+2*2*2
  919. .lignes_differentes:
  920.  
  921.     save.l a0-a1
  922.     lea liste_obj_redraw,a1
  923.     move.w #3,d2
  924.     bsr GWVA_FORM_WIND_OBJ_PRG_REDRAW_PART
  925.     load.l a0-a1
  926.  
  927. .deja_un_affichage:
  928. ; On met a jour le slider
  929.     move.l table_obj(a1),a2
  930.     move.l add_struct_slide(a2),a3
  931.     add.l a0,a3
  932.     move.l offset_fichier(a1),d0
  933.     divu.l #8+8,d0
  934.     move.l d0,GWVA_FORM_SLIDER_OBJ_POS(a3)
  935.     save.l a0-a1
  936.     move.l GWVA_WIND_OBJ_SPEC_PTR(a0),a1
  937.  
  938.     move.l add_struct_slide(a2),a2
  939.     add.l a0,a2
  940.     bsr GWVA_SLIDER_OBJ_PRG_SET_SLIDER
  941.     load.l a0-a1
  942.  
  943.     clr d7
  944.     rts
  945.  
  946. .pas_deplacement:
  947.     move.w #GWVA_ERROR_GENERIC,d7
  948.     rts
  949.  BSS
  950. liste_obj_redraw:    ds.w 4*2+1
  951.  TEXT
  952.  
  953.     *-------------------------*
  954. ; Modification d'un quartet/octet du buffer
  955. ; a0=ptr fenetre visual
  956. ; a1=ptr fenetre look
  957. ; d0=digit
  958. affiche_digit:
  959.     move.l ad_buffer_source(a1),a2
  960.  
  961. ; positionnement au quartet
  962.     move.l pos_curseur(a1),d1
  963.     sub.l offset_fichier(a1),d1
  964.     sub.l offset_fichier(a1),d1
  965.     divu #2,d1            ; en octet
  966.     add.w d1,a2
  967.  
  968.     btst #0,champ_edition+1(a1)
  969.     bne.s .edition_ascii
  970.  
  971.     swap d1
  972.     tst d1
  973.     beq.s .quartet_haut
  974.     and.b #$f0,(a2)
  975.     or.b d0,(a2)
  976.     moveq #1,d2        ; deplacement en quartet
  977.     bra.s .continue
  978. .quartet_haut:
  979.     and.b #$0f,(a2)
  980.     lsl.b #4,d0
  981.     or.b d0,(a2)
  982.     moveq #1,d2        ; deplacement en quartet
  983.     bra.s .continue
  984. .edition_ascii:
  985.     move.b d0,(a2)
  986.     moveq #1*2,d2    ; deplacement en quartet
  987.  
  988. .continue:    move.w #-1,changement_valeur(a1)
  989.  
  990.     move.l d2,d0
  991.     move.w #0,d1
  992.  
  993.     bsr update_position_curs
  994.  
  995.     rts
  996.  
  997.     *-------------------------*
  998.  
  999. ; a0 : pointeur sur le nom du fichier
  1000. ; a2 : structure du type formulaire
  1001. create_a_look_window:
  1002.     lea add_structure_wind_look,a1
  1003.     clr.w d1
  1004. .search_last_wind_look:
  1005.     move.l (a1),d0
  1006.     beq .one_more_look_window
  1007.  
  1008.     add.w #3,d1
  1009.     cmp.w #GWVA_APP_OBJ_MAX_NUMBER_WIND-1,d1
  1010.     bge .no_more_look_window
  1011.  
  1012.     move.l d0,a1
  1013.     lea ptr_structure_wind_look(a1),a1
  1014.     bra.s .search_last_wind_look
  1015.  
  1016. .one_more_look_window:
  1017.     save.l a0-a2
  1018.     MXALLOC #RAM_TT_ST,#LONG_STR_LOOK+fin_fenetres_multi-fenetres_multi
  1019.     load.l a0-a2
  1020.     tst.l d0
  1021.     ble .pas_de_memoire
  1022.  
  1023.     move.l d0,(a1)        ; je stocke mon entrée dans la liste chainée
  1024.  
  1025.     move.l d0,a1        ; pointeur structure look
  1026.     clr.l ptr_structure_wind_look(a1)    ; mise à zéro de l'entré suivante (MALLOC pas mis à zero)
  1027.  
  1028.     move.l a1,a6        ; sauve pour les MFREE
  1029.  
  1030.     add.l #LONG_STR_LOOK,d0        ; d0 pointe sur l'espace réservé au structures fenetre VA
  1031.  
  1032.     move.l a0,a4        ; pointeur sur le nom du fichier
  1033.  
  1034.     lea fenetre_generale,a0
  1035.     move.l d0,a3
  1036.     move.l #fin_fenetres_multi-fenetres_multi,d1
  1037. .copy_structures:
  1038.     move.b (a0)+,(a3)+
  1039.     subq.l #1,d1
  1040.     bne.s .copy_structures
  1041.  
  1042.     move.l d0,a0        ; adresse fenetre generale
  1043.  
  1044.     save.l d0/a0-a2/a4/a6
  1045.     move.l add_ptr_copy_form(a2),a0
  1046.     move.l (a0),a0
  1047.     move.l #0,a1
  1048.     bsr GWVA_WFORM_OBJ_PRG_COPY_SAVED_FORM
  1049.     move.l a0,a3
  1050.     load.l d0/a0-a2/a4/a6
  1051.     tst d7
  1052.     bmi .erreur_copy1
  1053.  
  1054.     move.l a1,GWVA_WIND_OBJ_USER_PTR1(a0)
  1055.     move.l #-1,GWVA_WIND_OBJ_FIRST_X(a0)    ; centre
  1056.     move.l a0,ptr_window(a1)
  1057.  
  1058.     lea source_pathname(a1),a5
  1059.     COPY_STRING_0 a4,a5
  1060.  
  1061.     save.l d0/a0-a3/a6
  1062.     lea source_pathname(a1),a0
  1063.     bsr GET_FILE_LENGTH
  1064.     move.l d0,d1
  1065.     load.l d0/a0-a3/a6
  1066.     tst.l d1
  1067.     ble .erreur_fichier
  1068.     move.l d1,source_length(a1)
  1069.  
  1070.     clr.l ad_buffer_source(a1)
  1071.     clr.w champ_edition(a1)        ; edition sur le champ hexa
  1072.     clr.l ad_buffer_search(a1)
  1073.     clr.l ptr_structure_wind_look(a1)
  1074.     move.l a2,table_obj(a1)
  1075.     move.l add_struct_form(a2),GWVA_WIND_OBJ_SPEC_PTR(a0)
  1076.     move.w f_size(a2),size_look(a1)
  1077.     move.l f_buffer_length(a2),buffer_length(a1)
  1078.     move.w f_num_line(a2),buffer_num_line(a1)
  1079.  
  1080.     move.l a0,d2
  1081.     add.l d2,GWVA_WIND_OBJ_SPEC_PTR(a0)
  1082.  
  1083.     move.l GWVA_WIND_OBJ_SPEC_PTR(a0),a1
  1084.     move.l a3,GWVA_WFORM_OBJ_CLONE_FORM_SAVE(a1)
  1085.  
  1086.     lea GWVA_WFORM_OBJ_START_OBJ_LIST+spec_fenetre_generale_b-fenetre_generale(a0),a2
  1087.     move.w #12-1,d1
  1088. .reloc_obj_gene_b:
  1089.     sub.l #fenetre_generale,GWVA_WFORM_OBJ_DEF_OBJ_PTR_STRUCT(a2)
  1090.     add.l d2,GWVA_WFORM_OBJ_DEF_OBJ_PTR_STRUCT(a2)
  1091.     lea GWVA_WFORM_OBJFORMLIST_LENGTH(a2),a2
  1092.     dbf d1,.reloc_obj_gene_b
  1093.  
  1094.     lea GWVA_WFORM_OBJ_START_OBJ_LIST+spec_fenetre_generale_s-fenetre_generale(a0),a2
  1095.     move.w #12-1,d1
  1096. .reloc_obj_gene_s:
  1097.     sub.l #fenetre_generale,GWVA_WFORM_OBJ_DEF_OBJ_PTR_STRUCT(a2)
  1098.     add.l d2,GWVA_WFORM_OBJ_DEF_OBJ_PTR_STRUCT(a2)
  1099.     lea GWVA_WFORM_OBJFORMLIST_LENGTH(a2),a2
  1100.     dbf d1,.reloc_obj_gene_s
  1101.  
  1102.     move.l d0,a0
  1103.     add.l #fenetre_offset-fenetre_generale,a0    ; fenetre offset
  1104.  
  1105.     save.l d0/a0-a2/a6
  1106.     move.l sauve_etat_formulaire_offset,a0
  1107.     move.l #0,a1
  1108.     bsr GWVA_WFORM_OBJ_PRG_COPY_SAVED_FORM
  1109.     move.l a0,a3
  1110.     load.l d0/a0-a2/a6
  1111.     tst d7
  1112.     bmi .erreur_copy2
  1113.  
  1114.     move.l a0,d2
  1115.     add.l d2,GWVA_WIND_OBJ_SPEC_PTR(a0)
  1116.  
  1117.     move.l GWVA_WIND_OBJ_SPEC_PTR(a0),a1
  1118.     move.l a3,GWVA_WFORM_OBJ_CLONE_FORM_SAVE(a1)
  1119.  
  1120.     lea GWVA_WFORM_OBJ_START_OBJ_LIST(a1),a2
  1121.  
  1122.     move.w #4-1,d1
  1123. .reloc_obj_offset:
  1124.     sub.l #fenetre_offset,GWVA_WFORM_OBJ_DEF_OBJ_PTR_STRUCT(a2)
  1125.     add.l d2,GWVA_WFORM_OBJ_DEF_OBJ_PTR_STRUCT(a2)
  1126.     lea GWVA_WFORM_OBJFORMLIST_LENGTH(a2),a2
  1127.     dbf d1,.reloc_obj_offset
  1128.  
  1129.     move.l d0,a0
  1130.     add.l #fenetre_search-fenetre_generale,a0
  1131.  
  1132.     save.l d0/a0-a2/a6
  1133.     move.l sauve_etat_formulaire_search,a0
  1134.     move.l #0,a1
  1135.     bsr GWVA_WFORM_OBJ_PRG_COPY_SAVED_FORM
  1136.     move.l a0,a3
  1137.     load.l d0/a0-a2/a6
  1138.     tst d7
  1139.     bmi.s .erreur_copy3
  1140.  
  1141.     move.l a0,d2
  1142.     add.l d2,GWVA_WIND_OBJ_SPEC_PTR(a0)
  1143.  
  1144.     move.l GWVA_WIND_OBJ_SPEC_PTR(a0),a1
  1145.     move.l a3,GWVA_WFORM_OBJ_CLONE_FORM_SAVE(a1)
  1146.  
  1147.     lea GWVA_WFORM_OBJ_START_OBJ_LIST(a1),a2
  1148.  
  1149.     move.w #6-1,d1
  1150. .reloc_obj_search:
  1151.     sub.l #fenetre_search,GWVA_WFORM_OBJ_DEF_OBJ_PTR_STRUCT(a2)
  1152.     add.l d2,GWVA_WFORM_OBJ_DEF_OBJ_PTR_STRUCT(a2)
  1153.     lea GWVA_WFORM_OBJFORMLIST_LENGTH(a2),a2
  1154.     dbf d1,.reloc_obj_search
  1155.  
  1156.     move.l a6,a1
  1157.  
  1158.     clr d7
  1159.     rts
  1160.  
  1161. .erreur_copy3:
  1162.     move.l d0,a0
  1163.     add.l #fenetre_offset-fenetre_generale,a0
  1164.     move.l GWVA_WIND_OBJ_SPEC_PTR(a0),a1
  1165.     save.l a6
  1166.     MFREE GWVA_WFORM_OBJ_CLONE_FORM_SAVE(a1)
  1167.     load.l a6
  1168. .erreur_copy2:
  1169.     move.l d0,a0
  1170.     move.l GWVA_WIND_OBJ_SPEC_PTR(a0),a1
  1171.     save.l a6
  1172.     MFREE GWVA_WFORM_OBJ_CLONE_FORM_SAVE(a1)
  1173.     load.l a6
  1174. .erreur_copy1:
  1175.     MFREE a6
  1176. .pas_de_memoire:
  1177.     move.w #ALERT_MEM,d0
  1178.     move.w #1,d1
  1179.     bsr RSC_ALERT_BOX
  1180.     bra .delete_entry_in_chain_list
  1181.  
  1182. .erreur_fichier:
  1183.     save.l a6
  1184.     MFREE a3        ; elimine la copie du formulaire generale
  1185.     load.l a6
  1186.  
  1187.     MFREE a6
  1188.     move.w #ALERT_OPEN_FILE,d0
  1189.     move.w #1,d1
  1190.     bsr RSC_ALERT_BOX
  1191.  
  1192. .delete_entry_in_chain_list:
  1193.     lea add_structure_wind_look,a1
  1194. .search_wind_look:
  1195.     move.l (a1),a2
  1196.     tst.l ptr_structure_wind_look(a2)    ; dernière structure ?
  1197.     beq.s .delete_entry
  1198.     lea ptr_structure_wind_look(a2),a1
  1199.     bra.s .search_wind_look
  1200. .delete_entry:
  1201.     clr.l (a1)
  1202. .no_more_look_window:
  1203.     move.w #GWVA_ERROR_GENERIC,d7
  1204.     rts
  1205.     
  1206.     *-------------------------*
  1207.  
  1208. ; a0 : nom du fichier, a2 : structure du type formulaire
  1209. create_open_a_look_window:
  1210.     save.l a0
  1211.     bsr create_a_look_window    ; retour dans a1 de l'adresse de la structure look
  1212.     load.l a0
  1213.     tst d7
  1214.     bge.s open_a_look_window
  1215.     rts
  1216.  
  1217. open_a_look_window:
  1218.     save.l a0-a1
  1219.     move.l ptr_window(a1),a0
  1220.     bsr GWVA_WIND_OBJ_PRG_CREATE_OPEN_ONE_WIND
  1221.     load.l a0-a1
  1222.     tst d7
  1223.     bmi.s .erreur_open
  1224.  
  1225.     bsr open_a_file
  1226.     tst d7
  1227.     bmi.s .erreur_open
  1228.     rts
  1229. .erreur_open:
  1230.     move.l ptr_window(a1),a0
  1231.     bsr free_a_look_window
  1232.     rts
  1233.  
  1234. close_a_look_window:
  1235.     tst.l ad_buffer_source(a1)
  1236.     beq .buffer_vide
  1237.  
  1238.     save.l a1
  1239.     move.w #2,d0        ; par défaut No
  1240.     bsr save_buffer_if_changed
  1241.     load.l a1
  1242.  
  1243. .buffer_vide:
  1244.     bsr free_a_look_window
  1245.     rts
  1246.  
  1247.  DATA
  1248. texte_selecteur_l:    dc.b 'Choose file to look & edit :',0
  1249. mask_selecteur_l:    dc.b '*.*',0
  1250.  TEXT
  1251.  
  1252.     *-------------------------*
  1253.  
  1254. free_all_look_window:
  1255.     move.l add_structure_wind_look,a1
  1256. .free_all_look_w:
  1257.     cmp.l #0,a1
  1258.     beq.s .pas_fenetre
  1259.  
  1260.     move.l ptr_window(a1),a0
  1261.     save.l a1
  1262.     bsr close_fenetre_generale
  1263.     load.l a1
  1264.     move.l ptr_structure_wind_look(a1),a1
  1265.     bra.s .free_all_look_w
  1266.  
  1267. .pas_fenetre:
  1268.     rts
  1269.     
  1270.     *-------------------------*
  1271.  
  1272. free_a_look_window
  1273.     cmp.l #0,a1
  1274.     beq .nothing1
  1275.  
  1276.     move.l ptr_window(a1),a0
  1277.     save.l a0-a1
  1278.     bsr GWVA_WIND_OBJ_PRG_DELETE_ONE_WIND    ; le clone est automatiquement detruit lors du "DELETE" de la fenêtre
  1279.     load.l a0-a1
  1280.  
  1281.     save.l a0-a1            ; on libere le formulaire de 'go offset'
  1282.     lea fenetre_offset-fenetre_generale(a0),a0
  1283.     move.l GWVA_WIND_OBJ_SPEC_PTR(a0),a1
  1284.     save.l a0-a1
  1285.     MFREE GWVA_WFORM_OBJ_CLONE_FORM_SAVE(a1)
  1286.     load.l a0-a1
  1287.     clr.l GWVA_WFORM_OBJ_CLONE_FORM_SAVE(a1)
  1288.     bsr GWVA_WIND_OBJ_PRG_DELETE_ONE_WIND
  1289.     load.l a0-a1
  1290.  
  1291.     save.l a0-a1            : on libere le formulaire de 'search'
  1292.     lea fenetre_search-fenetre_generale(a0),a0
  1293.     move.l GWVA_WIND_OBJ_SPEC_PTR(a0),a1
  1294.     save.l a0-a1
  1295.     MFREE GWVA_WFORM_OBJ_CLONE_FORM_SAVE(a1)
  1296.     load.l a0-a1
  1297.     clr.l GWVA_WFORM_OBJ_CLONE_FORM_SAVE(a1)
  1298.     bsr GWVA_WIND_OBJ_PRG_DELETE_ONE_WIND
  1299.     load.l a0-a1
  1300.  
  1301.     tst.l ad_buffer_source(a1)
  1302.     beq .nothing2
  1303.     save.l a1
  1304.     MFREE ad_buffer_source(a1)
  1305.     load.l a1
  1306.     clr.l ad_buffer_source(a1)
  1307. .nothing2:
  1308.     tst.l ad_buffer_search(a1)
  1309.     beq .nothing3
  1310.     save.l a1
  1311.     MFREE ad_buffer_search(a1)
  1312.     load.l a1
  1313.     clr.l ad_buffer_search(a1)
  1314. .nothing3:
  1315.  
  1316. ; On va enlever notre fenetre look de la liste chainée des structure look
  1317.     move.l ptr_structure_wind_look(a1),a2
  1318.     lea add_structure_wind_look,a4
  1319. .je_me_cherche:
  1320.     move.l (a4),a3
  1321.     cmp.l a3,a1
  1322.     beq.s .fenetre_trouvee
  1323.     lea ptr_structure_wind_look(a3),a4
  1324.     bra.s .je_me_cherche
  1325.     
  1326. .fenetre_trouvee:
  1327.     move.l a2,(a4)
  1328.     
  1329.     MFREE a1    ; je libere la structure et les definitions des fenêtres
  1330.  
  1331. .nothing1:    rts
  1332.  
  1333.     *-------------------------*
  1334.  
  1335.     ; a0 : ptr sur le nom du fichier, a1 : ptr structure look
  1336. open_a_file:
  1337.     save.l a1
  1338.     move.l buffer_length(a1),d0    ; longueur buffer
  1339.     bsr reserve_buffer
  1340.     load.l a1
  1341.     tst d7
  1342.     bmi .erreur_memoire
  1343.     move.l d0,ad_buffer_source(a1)
  1344.  
  1345.     clr.l offset_fichier(a1)
  1346.     clr.l pos_curseur(a1)        ; position dans le fichier
  1347.     clr.w changement_valeur(a1)
  1348.  
  1349.     save.l a1
  1350.     bsr load_a_buffer
  1351.     load.l a1
  1352.     tst d7
  1353.     bne .erreur_load
  1354.  
  1355.     moveq #0,d0
  1356.     save.l a1
  1357.     bsr deplace_dans_fichier
  1358.     load.l a1
  1359.  
  1360.     clr.w d7
  1361. .erreur:
  1362. .no_mem:    rts
  1363.  
  1364. .erreur_load:
  1365. .erreur_memoire:
  1366.     move.w #GWVA_ERROR_GENERIC,d7
  1367.     rts
  1368.  
  1369.     *-------------------------*
  1370.  
  1371. reserve_buffer:        ; d0=longeur, a1 : pointeur structure
  1372.     save.l a1
  1373.     MXALLOC #3,d0        ; TT -> ST
  1374.     load.l a1
  1375.     tst.l d0
  1376.     ble.s .errormem
  1377.     clr d7
  1378.     rts
  1379. .errormem:    move.w #ALERT_MEM,d0
  1380.     move.w #1,d1
  1381.     bsr RSC_ALERT_BOX
  1382.     moveq #GWVA_ERROR_MALLOC,d7
  1383.     rts
  1384.  
  1385.     *-------------------------*
  1386.  
  1387. ; a1 : ptr struc look
  1388. ; d0 : bouton par défaut
  1389. save_buffer_if_changed:
  1390.     tst.w changement_valeur(a1)
  1391.     beq .pas_de_chgt_valeur
  1392.  
  1393.     clr.w changement_valeur(a1)
  1394.  
  1395.     move.w d0,d1        ; bouton par défaut
  1396.     move.w #ALERT_MOD_B,d0
  1397.     save.l a1
  1398.     bsr RSC_ALERT_BOX
  1399.     load.l a1
  1400.     cmp.w #2,d0
  1401.     beq .pas_de_sauvegarde
  1402.  
  1403.     save.l a1
  1404.     FILE_OPEN read_write,source_pathname(a1),d7
  1405.     load.l a1
  1406.     tst.w d7
  1407.     blt.s .pas_de_sauvegarde
  1408.  
  1409.     save.l a1
  1410.     FSEEK #0,d7,offset_fichier(a1)
  1411.     load.l a1
  1412.     tst.l d0
  1413.     blt.s .pas_de_sauvegarde
  1414.  
  1415.     save.l a1
  1416.     move.l source_length(a1),d1
  1417.     sub.l offset_fichier(a1),d1
  1418.     move.l buffer_length(a1),d0
  1419.     cmp.l d0,d1
  1420.     bge.s .longueur_suffisante
  1421.     move.l d1,d0
  1422. .longueur_suffisante:
  1423.     FWRITE ad_buffer_source(a1),d0,d7
  1424.     FCLOSE d7
  1425.     load.l a1
  1426.  
  1427. .pas_de_chgt_valeur:
  1428.     clr.w d7
  1429.     rts
  1430. .pas_de_sauvegarde:
  1431.     move.w #-1,d7
  1432.     rts
  1433.  
  1434.     *-------------------------*
  1435.  
  1436. load_a_buffer:
  1437.     save.l a1
  1438.     FILE_OPEN read,source_pathname(a1),d7
  1439.     load.l a1
  1440.     tst d7
  1441.     ble .erreur_open
  1442.  
  1443.     save.l a1
  1444.     FSEEK #0,d7,offset_fichier(a1)
  1445.     move.l (sp),a1
  1446.     FREAD ad_buffer_source(a1),buffer_length(a1),d7
  1447.     move.l (sp),a1
  1448.  
  1449.     save.l d0
  1450.     FCLOSE d7
  1451.     load.l d0
  1452.  
  1453.     load.l a1
  1454.  
  1455.     tst.l d0
  1456.     blt .erreur_read
  1457.  
  1458.     cmp.l buffer_length(a1),d0
  1459.     beq.s .buffer_plein
  1460.  
  1461.     move.l ad_buffer_source(a1),a0
  1462.     add.l d0,a0
  1463.     sub.l buffer_length(a1),d0
  1464.     neg.w d0
  1465.     sub.w #1,d0
  1466. .efface_buff:
  1467.     move.b #'_',(a0)+
  1468.     dbf d0,.efface_buff
  1469. .buffer_plein:
  1470.     clr d7
  1471.     rts
  1472. .erreur_open:
  1473.     save.l a1
  1474.     move.w #ALERT_OPEN_FILE,d0
  1475.     move.w #1,d1
  1476.     bsr RSC_ALERT_BOX
  1477.     load.l a1
  1478.  
  1479.     move.w #GWVA_ERROR_GENERIC,d7
  1480.     rts
  1481.  
  1482. .erreur_read:
  1483.     save.l a1
  1484.     move.w #ALERT_READ_FILE,d0
  1485.     move.w #1,d1
  1486.     bsr RSC_ALERT_BOX
  1487.     load.l a1
  1488.  
  1489.     move.w #GWVA_ERROR_GENERIC,d7
  1490.     rts
  1491.  
  1492.     *-------------------------*
  1493. ; a1=ptr fenêtre look
  1494. ; d0.l=déplacement signé en quartet dans le fichier
  1495. deplace_dans_fichier:
  1496.     tst.l ad_buffer_source(a1)    ; ?PROT?
  1497.     beq .pas_fichier
  1498.  
  1499.     tst.l d0
  1500.     beq .pas_bouge
  1501.  
  1502.     asr.l #1,d0        ; quartet -> octet
  1503.     move.l offset_fichier(a1),d1
  1504.     add.l d0,d1
  1505.     bpl.s .offset_ok1
  1506.     clr.l d1
  1507. .offset_ok1:
  1508.     move.l source_length(a1),d2
  1509.     add.l #(8+8)-1,d2
  1510.     and.l #-(8+8),d2    ; d2 : longueur du fichier en multiple de (8+8)
  1511.     move.l buffer_length(a1),d3
  1512.     sub.l d3,d2
  1513.     bpl.s .positif
  1514.     clr.l d2
  1515. .positif:    
  1516.     cmp.l d2,d1
  1517.     ble.s .offset_ok2
  1518.     move.l d2,d1
  1519. .offset_ok2:
  1520.     move.l ad_buffer_source(a1),a0
  1521.  
  1522.     cmp.l offset_fichier(a1),d1
  1523.     beq .pas_deplacement
  1524.  
  1525.     save.l d1/a1
  1526.     move.w #2,d0
  1527.     bsr save_buffer_if_changed
  1528.     load.l d1/a1
  1529.  
  1530.     move.l d1,offset_fichier(a1)
  1531.  
  1532.     save.l a1
  1533.     bsr load_a_buffer
  1534.     load.l a1
  1535.     tst d7
  1536.     bne .erreur_load
  1537.  
  1538.     bsr update_text_dans_formulaire
  1539.  
  1540.     move.l ptr_window(a1),a0
  1541.     move.l table_obj(a1),a2
  1542.     move.w f_redraw_obj_2(a2),d0
  1543.     moveq #2,d1
  1544.     moveq #0,d2
  1545.     bsr GWVA_FORM_WIND_OBJ_PRG_REDRAW_PART
  1546.  
  1547.     clr.w d7
  1548.     rts
  1549.  
  1550. .pas_bouge:    bsr update_text_dans_formulaire
  1551.     move.w #GWVA_ERROR_GENERIC,d7
  1552.     rts
  1553.  
  1554. .erreur_load:
  1555. .pas_deplacement:
  1556. .pas_fichier:
  1557.     move.w #GWVA_ERROR_GENERIC,d7
  1558.     rts
  1559.  
  1560.     *-------------------------*
  1561. ; Om met à jour le ressource du formulaire avec le buffer
  1562. update_text_dans_formulaire:
  1563.     move.l offset_fichier(a1),d6
  1564.  
  1565.     move.l table_obj(a1),a2
  1566.     move.w f_offset_byte(a2),d1    ; move #FS_OFFSET_BYTE1,d1
  1567.  
  1568.     move.l ptr_window(a1),a0
  1569.     move.l GWVA_WIND_OBJ_SPEC_PTR(a0),a2
  1570.     move.w GWVA_WFORM_OBJ_FORM_IDX(a2),d0
  1571.  
  1572.     move.w buffer_num_line(a1),d7
  1573.     sub.w #1,d7
  1574.  
  1575.     save.l a1
  1576.  
  1577. .recopy_offset:
  1578.     save.w d0-d1/d7
  1579.  
  1580.     save.l d6
  1581.     bsr RETURN_TEXT_OBJ_IN_FORM_OBJ_PTR
  1582.     move.l (sp),d0
  1583.     move.l #32,d1
  1584.     bsr STOCK_HEXA
  1585.     load.l d6
  1586.  
  1587.     load.w d0-d1/d7
  1588.  
  1589.     add.w #1,d1
  1590.     add.l #(8+8),d6
  1591.     dbf d7,.recopy_offset
  1592.  
  1593.     load.l a1
  1594.  
  1595.     *-------*
  1596.  
  1597.     move.l ad_buffer_source(a1),a0
  1598.  
  1599.     move.l table_obj(a1),a2
  1600.     move.w f_donnees_byte(a2),d1    ; move #FS_DONNEES_BYTE,d1
  1601.  
  1602.     move.l ptr_window(a1),a2
  1603.     move.l GWVA_WIND_OBJ_SPEC_PTR(a2),a3
  1604.     move.w GWVA_WFORM_OBJ_FORM_IDX(a3),d0
  1605.  
  1606.     move.w buffer_num_line(a1),d7
  1607.     sub.w #1,d7
  1608.  
  1609.     save.l a1
  1610. .recopy_data:
  1611.     save.w d0-d1/d7
  1612.  
  1613.     save.l a0
  1614.     bsr RETURN_TEXT_OBJ_IN_FORM_OBJ_PTR
  1615.     load.l a0
  1616.  
  1617.     REPT 4
  1618.     move.l (a0)+,d0
  1619.     move.l #32,d1
  1620.     bsr STOCK_HEXA
  1621.     lea -1(a1),a1
  1622.     ENDR
  1623.  
  1624.     load.w d0-d1/d7
  1625.     add.w #1,d1
  1626.     dbf d7,.recopy_data
  1627.  
  1628.     load.l a1
  1629.  
  1630.     *------*
  1631.  
  1632.     move.l ad_buffer_source(a1),a0
  1633.  
  1634.     move.l table_obj(a1),a2
  1635.     move.w f_ascii_byte(a2),d1    ; move #FS_ASCII_BYTE,d1
  1636.  
  1637.     move.l ptr_window(a1),a2
  1638.     move.l GWVA_WIND_OBJ_SPEC_PTR(a2),a3
  1639.     move.w GWVA_WFORM_OBJ_FORM_IDX(a3),d0
  1640.  
  1641.     move.w buffer_num_line(a1),d7
  1642.     sub.w #1,d7
  1643.  
  1644.     save.l a1
  1645. .recopy_ascii:
  1646.     save.w d0-d1/d7
  1647.  
  1648.     save.l a0
  1649.     bsr RETURN_TEXT_OBJ_IN_FORM_OBJ_PTR
  1650.     load.l a0
  1651.  
  1652.     move.w #8+8-1,d6
  1653. .line_ascii:
  1654.     move.b (a0)+,d0
  1655.     cmp.b #$20,d0
  1656.     bge.s .ascii_affichable
  1657.     move.b #'.',d0
  1658. .ascii_affichable:
  1659.     move.b d0,(a1)+
  1660.     dbf d6,.line_ascii
  1661.  
  1662.     load.w d0-d1/d7
  1663.     add.w #1,d1
  1664.     dbf d7,.recopy_ascii
  1665.  
  1666.     load.l a1
  1667.  
  1668.     rts
  1669.  
  1670. *--------------------------------------------------------------------------*
  1671.     include search.s
  1672. *--------------------------------------------------------------------------*
  1673.     include offset.s
  1674. *--------------------------------------------------------------------------*
  1675.  
  1676.  DATA
  1677.     rsreset
  1678. add_struct_form:    rs.l 1
  1679. add_struct_slide:    rs.l 1
  1680. add_ptr_copy_form:    rs.l 1
  1681. f_redraw_obj_1:    rs.w 1
  1682. f_txt_name:        rs.w 1
  1683. f_txt_lgth_hex:    rs.w 1
  1684. f_txt_lgth_dec:    rs.w 1
  1685. f_redraw_obj_2:    rs.w 1
  1686. f_offset_byte:    rs.w 1
  1687. f_donnees_byte:    rs.w 1
  1688. f_ascii_byte:    rs.w 1
  1689. f_num_line:        rs.w 1
  1690. f_buffer_length:    rs.l 1
  1691. f_size:        rs.w 1
  1692.  
  1693. liste_obj_form_s:    dc.l spec_fenetre_generale_s-fenetre_generale
  1694.         dc.l struct_fs_slider-fenetre_generale
  1695.         dc.l sauve_etat_formulaire_s
  1696.         dc.w FS_REDRAW_OBJ_1
  1697.         dc.w FS_TXT_NAME
  1698.         dc.w FS_TXT_LGTH_HEX
  1699.         dc.w FS_TXT_LGTH_DEC
  1700.         dc.w FS_REDRAW_OBJ_2
  1701.         dc.w FS_OFFSET_BYTE
  1702.         dc.w FS_DONNEES_BYTE
  1703.         dc.w FS_ASCII_BYTE
  1704.         dc.w 8
  1705.         dc.l (8+8)*8
  1706.         dc.w 0
  1707.  
  1708. liste_obj_form_b:    dc.l spec_fenetre_generale_b-fenetre_generale
  1709.         dc.l struct_fb_slider-fenetre_generale
  1710.         dc.l sauve_etat_formulaire_b
  1711.         dc.w FB_REDRAW_OBJ_1
  1712.         dc.w FB_TXT_NAME
  1713.         dc.w FB_TXT_LGTH_HEX
  1714.         dc.w FB_TXT_LGTH_DEC
  1715.         dc.w FB_REDRAW_OBJ_2
  1716.         dc.w FB_OFFSET_BYTE
  1717.         dc.w FB_DONNEES_BYTE
  1718.         dc.w FB_ASCII_BYTE
  1719.         dc.w 16
  1720.         dc.l (8+8)*16
  1721.         dc.w 1
  1722.  
  1723.  BSS
  1724. add_structure_wind_look:    ds.l 1
  1725.             ds.w 1    ; BUG de DEVPAC : le dernier BSS ne doit pas être un .l
  1726.     rsreset
  1727. ptr_window:        rs.l 1    ; pointeur sur la str de la fenetre
  1728. source_pathname:    rs.b GWVA_MAX_PATH_LENGTH
  1729. source_length:    rs.l 1    ; taille du fichier
  1730. ad_buffer_source:    rs.l 1
  1731. buffer_length:    rs.l 1
  1732. buffer_num_line:    rs.w 1
  1733. offset_fichier:    rs.l 1    ; position actuelle de l'édition
  1734. pos_curseur:    rs.l 1    ; position du curseur dans le fichier
  1735. changement_valeur:    rs.w 1
  1736. champ_edition:    rs.w 1    ; bit 0 = 0 : edition hexa, 1 : edition ascii
  1737. size_look:        rs.w 1    ; 0 : small, 1 : big
  1738. table_obj:        rs.l 1    ; pointe sur la table d'objet correspondant a la taille
  1739.  
  1740. ad_fenetre_go_offset:    rs.l 1
  1741.  
  1742. ad_fenetre_search:    rs.l 1
  1743. longueur_chaine_search:    rs.w 1
  1744. chaine_search:    rs.b 128
  1745. ad_buffer_search:    rs.l 1
  1746. buffer_search_length:    rs.l 1
  1747. offset_search_fichier:    rs.l 1
  1748. pos_search_curseur:    rs.l 1
  1749.  
  1750. ptr_structure_wind_look:    rs.l 1
  1751. LONG_STR_LOOK:    rs.w 0
  1752. ; GWVA_WIND_OBJ_USER_PTR1 pointe sur cette structure
  1753.  
  1754.  END
  1755.